
import java.util.Scanner;
import Exception.*;
/**
 * @Author liangzai
 * @Description:
 */
class Login{
    private String name;
    private String password;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void loginFo(String name, String password){
        if(!this.name.equals(name)){
            throw new NameException("用户名错误！");
        }
        if(!this.password.equals(password)){
            throw new PasswordException("用户密码错误！");
        }
        System.out.println("登陆成功！");
    }
}

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Login login = new Login();

        login.setName("liangzai");
        login.setPassword("999");
        try {
            login.loginFo("liuzhi", "999");
        }catch (NameException e){
            login.loginFo("liangzai","999");
            System.out.println("重新登录！");
            e.printStackTrace();
        }catch (PasswordException e){
            login.loginFo("liangzai","999");
            System.out.println("重新登录！");
            e.printStackTrace();
        }finally {

        }
    }
}
